package UTS.controler;

import UTS.model.Dokumen;
import UTS.model.Surat;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author Vincentius HMK
 */
public class PengendaliPeriksaSuratDokumen {

    public static List<Surat> daftarPeriodeSurat(java.util.Date tglAwal, java.util.Date tglAkhir) {
        List<Surat> content = new ArrayList<Surat>();
        try {
            java.sql.Date mulai = new java.sql.Date(tglAwal.getTime());
            java.sql.Date akhir = new java.sql.Date(tglAkhir.getTime());
            ResultSet rs = Surat.getDaftarSurat(mulai, akhir);
            while (rs.next()) {
                Surat surat = new Surat();
                surat.setNomor(rs.getString(1));
                surat.setPerihal(rs.getString(2));
                surat.setAsal(rs.getString(3));
                surat.setPenerima(rs.getString(4));
                surat.setLetak(rs.getString(5));
                surat.setTanggalDiterima(rs.getDate(6));
                surat.setStatusSurat(rs.getString(7));
                content.add(surat);
            }
            return content;
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPeriksaSuratDokumen.class.getName()).log(Level.SEVERE, null, ex);
            return content;
        }
    }

    public static List<Dokumen> daftarPeriodeDokumen(java.util.Date tglAwal, java.util.Date tglAkhir) {
        List<Dokumen> content = new ArrayList<Dokumen>();
        try {
            java.sql.Date mulai = new java.sql.Date(tglAwal.getTime());
            java.sql.Date akhir = new java.sql.Date(tglAkhir.getTime());
            ResultSet rs = Dokumen.getDaftarDokumen(mulai, akhir);
            while (rs.next()) {
                Dokumen dokumen = new Dokumen();
                dokumen.setNomor(rs.getString(1));
                dokumen.setPerihal(rs.getString(2));
                dokumen.setAsal(rs.getString(3));
                dokumen.setPenerima(rs.getString(4));
                dokumen.setLetak(rs.getString(5));
                dokumen.setTanggalDiterima(rs.getDate(6));
                dokumen.setStatusDokumen(rs.getString(7));
                content.add(dokumen);
            }
            return content;
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPeriksaSuratDokumen.class.getName()).log(Level.SEVERE, null, ex);
            return content;
        }
    }
}
